package com.gmt.controller;

import com.gmt.pojo.User;
import com.gmt.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * @author John.zhang
 * @version Id: UserController, v 1.0 2020/11/12 15:23 ZhiYong Exp $
 */
@Controller
public class UserController {

    @Resource
    private IUserService userService;

    @RequestMapping("/{page}")
    public String showPage(@PathVariable String page){
        return page;
    }

    @RequestMapping("/user/query")
    public String query(Model model){
        model.addAttribute("list",userService.query(null));
        return "user";
    }

    @RequestMapping("/user/add")
    public String add(Model model){
        return "redirect:/user/query";
    }

    @RequestMapping("/user/updateInfo")
    public String updateInfo(Integer id,Model model){
        model.addAttribute("user",new User());
        return "updateUser";
    }

}
